<template>
	<view class="settings" v-if="member">
		<!-- 顶部导航 -->
		<diyNavBar value='个人设置'></diyNavBar>
		<!-- 头像 -->
		<view class="public image">
			<text class="name">头像</text>
			<view class="image-to" @click="$util.redirectTo('/pages/modifyInformation/modifyInformation')">
				<image :src="$util.img(member.avatar)" mode=""></image>
				<text class="iconfont icon-jinrujiantou"></text>
			</view>
		</view>
		<!-- 信息 -->
		<view class="information">
			<view class="public image">
				<text class="name">昵称</text>
				<text class="title">{{member.nickname}}</text>
			</view>
			<view class="public image" @click="$util.redirectTo('/pages/modifyphone/modifyphone')">
				<text class="name">手机号</text>
				<view class="image-to">
					<text class="title">{{member.mobile}}</text>
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>
		</view>
		<!-- 另外 -->
		<view class="information">
			<view class="public image"@click="$util.redirectTo('/pages/alipay/alipay')">
				<text class="name">绑定支付宝</text>
				<view class="image-to" >
					<text class="title">{{member.ali_number}}</text>
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>
			<view class="public image"@click="$util.redirectTo('/pages/wxalipay/wxalipay')">
				<text class="name">绑定微信</text>
				<view class="image-to" >
					<text class="title">{{member.wx_name}}</text>
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>
			<view class="public image"@click="$util.redirectTo('/pages/aboutus/aboutus')">
				<text class="name">关于我们</text>
				<view class="image-to" >
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>
			<view class="public image" @click="$util.redirectTo('/pages/agreement/agreement',{title:'服务协议',type:'Services'})">
				<text class="name">服务协议</text>
				<view class="image-to">
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>
			<view class="public image" @click="$util.redirectTo('/pages/agreement/agreement',{title:'隐私协议',type:'Privacy'})">
				<text class="name">隐私协议</text>
				<view class="image-to">
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>
			<view class="public image" @click="$util.redirectTo('/pages/guide/guide')">
				<text class="name">新手指南</text>
				<view class="image-to">
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>

			<!-- <view class="public image" @click="xz">
				<text class="name">下载</text>
				<view class="image-to">
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view> -->
		</view>
		<view class="public image" @click="logoff">
			<text class="name">账号注销</text>
			<view class="image-to">
				<text class="iconfont icon-jinrujiantou"></text>
			</view>
		</view>
		<loading-cover ref="loadingCover"></loading-cover>
		<!-- 退出登录 -->
		<view class="logindelete" @click="deletetoken">退出登录</view>
	</view>
</template>

<script>
	import loadingCover from '../../component/loading-cover/loading-cover.vue'
	import diyNavBar from '../../component/diy-nav/diy-navbar.vue'
	export default{
		components:{diyNavBar,loadingCover},
		data(){
			return {
				member:{}
			}
		},
		onShow() {
			this.$http.sendrequest('/member/Personalsz',{},{
				tokenJudge:true
			}).then(res=>{
				if(res.code == 1) {
					this.member = res.data;
					this.$refs.loadingCover.hide();
				}
			})
			this.$forceUpdate();
		},
		methods:{
			deletetoken(){
				this.$http.sendrequest('/login/logOut',{},{
					tokenJudge:true
				}).then(res=>{
					uni.showToast({title:res.msg,icon:'none'})
					if(res.code == 1){
						uni.removeStorageSync('token');
						setTimeout(()=>{
							this.$util.redirectTo('/pages/login/login',{},'reLaunch');
						},1000)
					}
				})
			},
			xz(){
				let ua = uni.getSystemInfoSync().platform;
				let status;
				if (/ios/i.test(ua)) {
					status = 2
				} else if (/android/i.test(ua)) {
					status = 1
				}
				this.$http.sendrequest('/index/xz',{status},{
					tokenJudge:true
				}).then(res=>{
					// #ifdef H5
					window.location.href = res.data;
					// #endif
					// #ifdef APP
					plus.runtime.openURL(res.data);
					// #endif
				})
			},
			logoff(){
				uni.showModal({
					content:'是否确定要注销账号？',
					success:res=>{
						console.log("确定",res)
						if(res.confirm) {
							this.$http.sendrequest('/member/logoutmember','',{
								tokenJudge:true
							}).then(res=>{
								uni.showToast({title:res.msg,icon:'none'})
								if(res.code == 1){
									uni.clearStorage();
									setTimeout(()=>{
										this.$util.redirectTo('/pages/login/login',{},'reLaunch');
									},1000)
								}
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.settings{
		min-height: 100vh;
		background: $uni-content-background-color;
		.public{
			padding: 0 30rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1rpx solid rgba(0,0,0,.06);
			height: 120rpx;
			.name{
				font-size: 30rpx;
				// font-weight: bold;
			}
			.title{
				color: #666666;
				font-size: 30rpx;
			}
			.icon-jinrujiantou{
				font-size: 46rpx;
				color: #C6C9CC;
			}
		}
		.image{
			.image-to{
				display: flex;
				align-items: center;
				image{
					width: 80rpx;
					height: 80rpx;
					margin-right: 12rpx;
					border-radius: 50%;
				}
				.text{
					font-size: 26rpx;
				}
			}
		}
		.information{
			margin: 20rpx 0;
		}
		.logindelete{
			background: #FFFFFF;
			height: 120rpx;
			font-size: 32rpx;
			color: #FF5A57;
			text-align: center;
			justify-content: center;
			margin-top:32rpx;
			line-height: 120rpx;
		}
	}
</style>
